package game;

public class StringBoard extends TicTacToeBoard{
	
	public static final String X = "X"; 
	public static final String O = "O"; 
	String gridString = ""; 
	
	public void createGrid(){
		gridString = "ZZZZZZZZZ"; 
	}
	
	public void reset(){
		if(gameOver == true){
			gridString = "ZZZZZZZZZ"; 
		}
	}
	
	protected void makeMove(int s, int m){
		 String move = gridString.substring(s, s+1); 
		 String front = gridString.substring(0, s-1); 
		 String back = gridString.substring(s+1, 8); 
		 if(m == 0){
			 move ="X"; 
		 } else{
			 move = "O"; 
		 }
		 gridString = front + move + back; 
	}
	
	public boolean checkFree(int s){
		if(gridString.substring(s, s+1).equals("Z")){
			return true; 
		} else {
			return false; 
		}
	}
	
	public int getValue(int s){
		int x = 0;
		String temp = gridString.substring(s, s+1); 
		if(temp.equals("Z")){
			x = -1; 
			return x; 
		}
		if(temp.equals("X")){
			x = 0; 
			return x; 
		}
		if(temp.equals("O")){
			x = 1; 
			return x;
		} else {
			x = -2;
			return x; 
		}
	}
}